<template>
  <svg :class="svgClass" :style="svgStyle" aria-hidden="true">
    <use :xlink:href="iconClassName" />
  </svg>
</template>

<script setup name="SvgIcon">
import { computed } from 'vue'
const props = defineProps({
  iconName: {
    type: String,
    required: true
  },
  className: {
    type: String,
    default: ''
  },
  size: {
    type: Number,
    default: 14
  }
})
const iconClassName = computed(() => {
  return `#${props.iconName}`
})
const svgClass = computed(() => {
  if (props.className) {
    return `svg-icon ${props.className}`
  }
  return 'svg-icon'
})
const svgStyle = computed(() => {
  return {
    width: props.size + 'px',
    height: props.size + 'px'
  }
})
</script>

<style lang="less" scoped>
.svg-icon {
  margin: auto;
}
</style>
